/**
 *
 * @description:
 * @author: junyong.hong
 * @createTime: 2018/5/8
 * @version: 1.0.0.0
 * @history:
 *    1、
 *    2、
 *
 */
import createApp from './create-app'

export default context => {
  return new Promise((resolve, reject) => {
    const { app, router } = createApp()

    router.push(context.url)

    router.onReady(() => {
      const matchedComponents = router.getMatchedComponents()

      if (!matchedComponents.length) {
        return reject(new Error('no component matched'))
      }
      context.meta = app.$meta()
      resolve(app)
    })
  })
}
